/**
 * Created by Kpeng on 2017/7/3.
 * Depending on the jquery-1.12.4.min.js.
 * Depending on the common.js.
 * Depending on the style.min.css.
 * To cite this document, always state the source as shown above.
 * -------------------------------
 * Module:个人消息
 * -------------------------------
 */

$(function () {
    wzERP.Message.init();
});

wzERP.Message.init = function () {
    wzERP.Common.inlineDate('#rangestart', '#rangeend');  //联动日期
    wzERP.Common.checkAllTr('.selecte-all');    //全选
    wzERP.Message.turnPage();//分页
    wzERP.Message.viewDetail();//查看详情
    wzERP.Message.markRead();//标记已读
    wzERP.Message.delHandle();//删除已选
};

//查看详情
wzERP.Message.viewDetail = function () {
    var opt = {
        ele: '.view',
        modalBox: '#modal',
        modalTitleStr: '消息详情',
        onApprove: function () {
            alert('ccc');
        },
        snippets: $("#messageDetailHtml").val()
    };
    wzERP.Common.handleData(opt);
};

//分页跳转
wzERP.Message.turnPage = function () {
    var opt = {
        pageUrl: "",
        pageSearch: "#searchForm",
        pagesTotal: parseInt($('#pages').val()),
        pageCurr: parseInt($('#current').val()),
        currId: '#current'
    };
    wzERP.Common.pagingHandle(opt);
};

//标记已读
wzERP.Message.markRead = function () {
    var opt = {
        btn: '.markBtn',
        list: '.selecte-all tbody'
    };
    wzERP.Common.markHandle(opt)
};

//删除
wzERP.Message.delHandle = function () {
    var opt = {
        container: '.selecte-all',
        delBtn: '.delBtn',
        delFn: function () {
            console.log(opt.ids);
            layer.msg('删除成功', {
                icon: 6,
                time: 20000, //20s后自动关闭
            });
        },
    };
    wzERP.Common.editCheckTable(opt);
};